package com.boshao.classschedule.adapter;

import com.boshao.classschedule.fragment.CalendarFragment;
import com.boshao.classschedule.fragment.ClassScheduleFragment;
import com.boshao.classschedule.fragment.OtherFragment;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

/**
 * 主界面的ViewPager的Adapter
 * @author boshao
 *
 */
public class MainFragmentAdapter extends FragmentStatePagerAdapter{
	private int mCount;
	public MainFragmentAdapter(FragmentManager fm,int count) {
		super(fm);
		mCount = count;
	}

	/**
	 * 获取相应位置的Fragment
	 */
	@Override
	public Fragment getItem(int position) {
		Fragment fragment = null;
		fragment = position == 0 ?CalendarFragment.newInstance() : 
			position == 1? ClassScheduleFragment.newInstance() : OtherFragment.newInstance();
		return fragment;
	}

	@Override
	public int getCount() {
		return mCount;
	}
}
